package com.lanxi.nbpaytest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class NbPaytestApplication {

    public static void main(String[] args) {
        SpringApplication.run(NbPaytestApplication.class, args);
    }

//    @Override
//    public void run(String... args) throws Exception {
//        String pfxPath = "";
//        String pfxPwd = "";
//        String certPath = "";
//        String appId = "old3000160000";
//        String reqUrl = "http://aap-test.nbcb.com.cn:20380/pay/api/v1/tradePagePay";
//
//        // notifyUrl为后端跳转url，自定义一个接口，成功后回调该接口，payFrontUrl为前端跳转url
//        String body = "{\"channelType\":\"00\",\"merApplyDateTime\":\"2019-07-02 15:11:14\",\"merApplySeqNo\":\""
//                + RandomUtils.randomFlowNo()
//                + "\",\"merId\":\"333021258121280\",\"notifyUrl\":\"www.baidu.com\",\"orderDesc\":\"miaoshu\",\"payFrontUrl\":\"www.jingdong.com\",\"platformId\":\"333021258121280\",\"terminalType\":\"01\",\"transAmt\":2.2}";
//
//        String rootPath = this.getClass().getResource("/").getFile();
//        pfxPath = rootPath + appId + "/" + appId + ".pfx";
//        certPath = rootPath + appId + "/" + appId + ".cer";
//        pfxPwd = "123456";
//        PayUtil.init(pfxPath, pfxPwd, certPath);
//
//        System.out.println("签名原文：" + body);
//        String signMsg = PayUtil.sign(body);
//        System.out.println("签名值：" + signMsg);
//        System.out.println(PayUtil.validate(body, signMsg));
//        // 获取支付表单
//        String result = PayUtil.createAutoFormSubmitHtml(appId, reqUrl, body, signMsg);
//        System.out.println(result);
//
//        String post = PayUtil.post(appId, reqUrl, result);
//        System.out.println(post);
//    }
}
